from tkinter import *
from tkinter import ttk

# canvas demo https://tkdocs.com/tutorial/canvas.html

root = Tk()
root.title("first canvas")
# 设置宽高
root.geometry('600x600')
# 创建画布
canvas = Canvas(root, width=500, height=400, background='white')
# 绘制线段
canvas.create_line(10, 5, 200, 50, fill='red', width=3)
# 绘制矩形x1,y1,x2,y2
canvas.create_rectangle(10, 50, 200, 200, fill='red', outline='blue')
canvas.create_rectangle(10, 210, 200, 310, outline='blue')
# 绘制文本
canvas.create_text(200, 10, text='A wonderful story', anchor='nw', font='TkMenuFont', fill='red')
# 将控件放置到主窗口中
canvas.pack()

root.mainloop()